#region Usings

using System;
using System.Collections.Generic;
using System.Linq;
using Rail.Net.Core.Interfaces.Data;
using Rail.Net.Core.Model;

#endregion

namespace Rail.Net.Data
{
    public class PriceSerialRepository : Repository<PriceSerial>, IPriceSerialRepository
    {
        public override IQueryable<PriceSerial> AllDefaultsIncluded()
        {
            return All(p => p.Ru);
        }

        #region IPriceSerialRepository Members

        public IEnumerable<PriceSerial> GetPriceSerials(RelationRu relationRu)
        {
            return AllDefaultsIncluded().Where(
                p =>
                p.Ru.Id == relationRu.Ru.Id && p.Serial == relationRu.Serial && p.TarifNumber == 1 &&
                p.ValidFrom <= DateTime.Now && p.ValidTo >= DateTime.Now);
        }

        #endregion
    }
}